<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>发送GET请求</button>
  <button>发送POST请求</button>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.0.0-alpha.1/axios.js"></script>
<script>
  const btn = document.querySelectorAll('button')
  btn[0].onclick = () => {
    axios.get(`http://127.0.0.1:8089/api/get?name=zs&age=20`).then((res) => {
      console.log(res);
    }).catch((err) => {
      console.log(err.message);
    })
  }
  btn[1].onclick = () => {
    axios.post('http://127.0.0.1:8089/api/post', {
      book: '西游记',
      author: '吴承恩'
    }).then((res) => {
      console.log(res);
    }).catch((err) => {
      console.log(err.message);
    })
  }
</script>

</html>